package band.wukong.practice.java.core.topic.generic;

import java.util.Random;

/**
 * @author wukong(wukonggg@139.com)
 */
public class GenericInterfaceSample {

    public static void main(String[] args) {
        Generator g = new FruitGenerator();
        System.out.println(g.next());
        System.out.println(g.next());
        System.out.println(g.next());
    }


    private static interface Generator<T> {
        public T next();
    }

    private static class FruitGenerator implements Generator<String> {

        private String[] fruits = new String[]{"Apple", "Pen", "Banana"};

        @Override
        public String next() {
            return fruits[new Random().nextInt(fruits.length)];
        }
    }
}
